layui.use(['upload'], function () {
    const upload = layui.upload,
        $ = layui.jquery;

    upload.render({
        elem: '#ID-upload-product-choose',
        url: URL_SYSTEM_PRODUCT_IMPORT,
        auto: false,
        accept: 'file',
        exts: 'xls|xlsx|xlsm',
        size: 10240,
        bindAction: '#ID-upload-product-action',
        done: function (res) {
            let icon;
            if (res.code !== 0) {
                icon = 2;
            } else {
                icon = 1;
            }
            layer.alert(JSON.stringify(res), {
                icon: icon,
            });
        }
    });

    // 下载模版
    $("#ID-download-product-template").click(function () {
        window.location.href = "/system/template/download";
    });
});